package cn.yyh.servicePay.controller;

import cn.yyh.commons.utils.R;
import cn.yyh.servicePay.domain.PayBill;
import cn.yyh.servicePay.service.IPayBillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 杨永航
 * @version 1.0
 * @Title: PayBillController
 * @Package: cn.yyh.servicePay.controller
 * @date 2021/7/10
 */
@RestController
@RequestMapping("/servicePay/bill")
public class PayBillController {
    @Autowired
    private IPayBillService payBillService;

    @PostMapping
    public R save(@RequestBody PayBill payBill) {
        try {
            payBillService.save(payBill);
            System.out.println(payBill);
            return R.oK().data("bill",payBill);
        } catch (Exception e) {
            e.printStackTrace();
            return R.error();
        }
    }

    @PostMapping("pay")
    public String pay(@RequestBody PayBill payBill) {
        try {
            return payBillService.pay(payBill);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
